;
; gdt.s
; function to create GDT
; Tan Menglong <TanMenglong@gmail.com>
; 13-Apr-08
;

[GLOBAL flush_gdt]

flush_gdt:
	mov eax, [esp+4]	; Get the pointer to the GDT, passed as a parameter by C code.
	lgdt [eax]		; Load the new GDT pointer

	mov ax, 0x10		; 0x10 is the offset in the GDT to our data segment
	mov ds, ax		; Load all data segment selectors
	mov es, ax
	mov fs, ax
	mov gs, ax
	mov ss, ax
	jmp 0x08:.flush
.flush:
	ret

[GLOBAL flush_idt]

flush_idt:
    mov eax, [esp+4]  ; Get the pointer to the IDT, passed as a parameter. 
    lidt [eax]        ; Load the IDT pointer.
    ret
